package com.wxl.common.room.database;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.wxl.common.room.dao.AuthorizeTermDao;
import com.wxl.common.room.dao.BlastDao;
import com.wxl.common.room.dao.BlastLeiGuanDao;
import com.wxl.common.room.dao.BlastRecordDao;
import com.wxl.common.room.dao.CollectorDao;
import com.wxl.common.room.dao.ContractInfoDao;
import com.wxl.common.room.dao.DetonatorDao;
import com.wxl.common.room.dao.LeiGuanDao;
import com.wxl.common.room.dao.LeiGuanDelayDao;
import com.wxl.common.room.dao.OperateLogDao;
import com.wxl.common.room.dao.QusetionDao;
import com.wxl.common.room.dao.QusetionItemDao;
import com.wxl.common.room.dao.UnApplyBlastDao;
import com.wxl.common.room.dao.UserDao;
import com.wxl.common.room.entity.AuthorizeTermEntity;
import com.wxl.common.room.entity.BlastLGRecordEntity;
import com.wxl.common.room.entity.BlastRecordEntity;
import com.wxl.common.room.entity.CollectorBean;
import com.wxl.common.room.entity.ContractInfoEntity;
import com.wxl.common.room.entity.DetonatorEntity;
import com.wxl.common.room.entity.LeiGuanBlastEntity;
import com.wxl.common.room.entity.LeiGuanDelayEntity;
import com.wxl.common.room.entity.LeiGuanEntity;
import com.wxl.common.room.entity.LogEntity;
import com.wxl.common.room.entity.QuestionEntity;
import com.wxl.common.room.entity.QuestionItemEntity;
import com.wxl.common.room.entity.UnApplyBlastEntity;
import com.wxl.common.room.entity.UserEntity;

@Database(entities = {UserEntity.class, DetonatorEntity.class,
        AuthorizeTermEntity.class, CollectorBean.class, LeiGuanEntity.class,
        UnApplyBlastEntity.class, ContractInfoEntity.class, LeiGuanDelayEntity.class
        , BlastRecordEntity.class, BlastLGRecordEntity.class, LogEntity.class
        , QuestionItemEntity.class, QuestionEntity.class, LeiGuanBlastEntity.class}, version = 1)
public abstract class DataBase extends RoomDatabase {

    private static DataBase mDataBase;


    public static synchronized DataBase getInstance(Context mContext) {
        if (mDataBase == null) {
            mDataBase = Room.databaseBuilder(mContext.getApplicationContext(), DataBase.class, "db_blast")
                    //.allowMainThreadQueries()
                    //不允许在主线程对数据库进行操作,为了方便测试可以加入该方法强行允许在主线程进行CURD操作
                    .build();
        }
        return mDataBase;
    }

    public abstract UserDao getUserDao();

    public abstract DetonatorDao getDetonatorDao();

    public abstract AuthorizeTermDao getAuthorizeTermDao();

    public abstract CollectorDao getCollectorDao();

    public abstract LeiGuanDao getLeiGuanDao();

    public abstract UnApplyBlastDao getUnApplyBlastDao();

    public abstract ContractInfoDao getContractInfoDao();

    public abstract LeiGuanDelayDao getLeiGuanDelayDao();

    public abstract BlastRecordDao getBlastRecordDao();

    public abstract BlastLeiGuanDao getBlastLeiGuanDao();

    public abstract OperateLogDao getOperateLogDao();

    public abstract QusetionItemDao getQusetionItemDao();

    public abstract QusetionDao getQusetionDao();

    public abstract BlastDao getBlastDao();
}
